import BaseService from './BaseService.js';

class OrderService extends BaseService{
  constructor() {
    super()
    // `$$prefix` 将自动加在 `url` 前面，除非 `url` 是一个绝对 URL
    this.$$prefix = '/v0/order';
  }

  list(params){
    return this.post(`list/page`, { data: params })
  }
  getOrderById(id){
    return this.get(`${id}`)
  }
  managerList(params) {
    return this.post(`manager/list`, { data: params })
  }
  /**创建订单 */
  save(params){
    return this.post('', { data: params })
  }
  /**修改订单 */
  update(params) {
    return this.put('', { data: params })
  }
  querList(params){
    return this.post(`list`, { data: params })
  }
  /**用户评价 */
  evaluate(params) {
    return this.put(`evaluate`, { data: params })
  }
  /**质量评价 */
  qualityEval(params){
    return this.put(`quality/evaluate/${params.factoryId}/${params.score}`, { data: params.evaluate })
  }
  /**支付评价 */
  payEval(params) {
    return this.put(`pay/evaluate/${params.businessId}/${params.score}`, { data: params.evaluate })
  }
  /**保证金退还 */
  bondBack(id){
    return this.put(`cash/money/back/${id}`)
  }
  /**延期退还保证金 */
  delayBack(id) {
    return this.put(`cash/delay/back/${id}`)
  }
  /**延期退还保证金结束后，退还保证金 */
  delayBondBack(id){
    return this.put(`cash/delaybond/back/${id}`)
  }
  /**获取预支付订单 */
  unifiedorder(orderCode){
    return this.get(`unifiedorder/${orderCode}`)
  }
  /**工厂竞标 */
  compete(orderId){
    return this.put(`compete/${orderId}`)
  }
  /**查询工厂是否对指定的订单投过标 */
  isCompete(orderId){
    return this.get(`compete/has/${orderId}`)
  }
  /**收藏订单 */
  favorite(orderId) {
    return this.put(`favorite/${orderId}`)
  }
  /**查询订单是否收藏 */
  isFavorite(orderId) {
    return this.get(`favorite/has/${orderId}`)
  }
  /**浏览订单 */
  browse(orderId){
    return this.put(`browse/${orderId}`,null, false);
  }
}

export default OrderService;